package com.zhanggm.springcloud.student.dao;

import com.zhanggm.springcloud.student.entity.AreaEntiy;
import com.zhanggm.springcloud.student.entity.StudentHobbyEntiy;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface StudentHobbyRepository extends JpaRepository<StudentHobbyEntiy,Long> {

    @Query(value = "select hobby_id from stu_sudent_hobby_relation where student_id=?1",nativeQuery = true)
    List<Long> findByStudentId(Long studentId);

    @Transactional
    @Modifying
    @Query(value = "delete from stu_sudent_hobby_relation where student_id=?1",nativeQuery = true)
    void deleteByStudentId(Long studentId);
}
